import pygame
import sys
from init_map import InitMap


class Map(InitMap):
    def __init__(self, *args):
        InitMap.__init__(self)

        self.key_yellow = pygame.image.load("../资源/图片/黄钥匙.jpg").convert_alpha()
        self.door_yellow = pygame.image.load("../资源/图片/黄门.jpg").convert_alpha()
        self.door_blue = pygame.image.load("../资源/图片/蓝门.png").convert_alpha()
        self.door_red = pygame.image.load("../资源/图片/红门.jpg").convert_alpha()
        self.hp_blue = pygame.image.load("../资源/图片/蓝药.jpg").convert_alpha()
        self.gem_blue = pygame.image.load("../资源/图片/蓝宝石.jpg").convert_alpha()
        self.gem_red = pygame.image.load("../资源/图片/红宝石.jpg").convert_alpha()
        self.big_coin = pygame.image.load("../资源/图片/大金币.png").convert_alpha()
        self.little_feather = pygame.image.load("../资源/图片/小飞羽.png").convert_alpha()
        self.big_bat = pygame.image.load("../资源/图片/大蝙蝠.png").convert_alpha()
        self.primary_guard = pygame.image.load("../资源/图片/初级卫兵.png").convert_alpha()
        self.kulou_leader = pygame.image.load("../资源/图片/骷髅队长.png").convert_alpha()
        self.red_bat = pygame.image.load("../资源/图片/红蝙蝠.png").convert_alpha()
        self.senior_master = pygame.image.load("../资源/图片/高级法师.png").convert_alpha()
        self.stone_man = pygame.image.load("../资源/图片/石头怪人.png").convert_alpha()
        self.monster_king = pygame.image.load("../资源/图片/怪王.png").convert_alpha()
        self.red_master = pygame.image.load("../资源/图片/红衣法师.png").convert_alpha()

        self.hero_pos = (9, 9)
        self.up_pos = (4, 10)
        self.down_pos = (9, 10)
        self.variable_pos = {
            (2, 8): (self.door_yellow, '黄门'),
            (3, 7): (self.door_yellow, '黄门'),
            (4, 8): (self.door_yellow, '黄门'),
            (6, 10): (self.door_yellow, '黄门'),
            (7, 10): (self.door_yellow, '黄门'),
            (9, 4): (self.door_yellow, '黄门'),
            (2, 2): (self.door_blue, '蓝门'),
            (4, 2): (self.door_blue, '蓝门'),
            (9, 8): (self.door_blue, '蓝门'),
            (3, 4): (self.door_red, '红门'),
            (0, 2): (self.key_yellow, '黄钥匙'),
            (1, 1): (self.key_yellow, '黄钥匙'),
            (5, 0): (self.key_yellow, '黄钥匙'),
            (6, 1): (self.key_yellow, '黄钥匙'),
            (7, 2): (self.key_yellow, '黄钥匙'),
            (4, 5): (self.key_yellow, '黄钥匙'),
            (5, 5): (self.key_yellow, '黄钥匙'),
            (6, 5): (self.key_yellow, '黄钥匙'),
            (9, 0): (self.hp_blue, '蓝药'),
            (10, 0): (self.hp_blue, '蓝药'),
            (10, 1): (self.hp_blue, '蓝药'),
            (3, 0): (self.gem_blue, '蓝宝石'),
            (3, 1): (self.gem_red, '红宝石'),
            (7, 0): (self.big_coin, '大金币'),
            (0, 0): (self.little_feather, '小飞羽'),
            (2, 7): (self.big_bat, '大蝙蝠'),
            (2, 9): (self.big_bat, '大蝙蝠'),
            (4, 7): (self.big_bat, '大蝙蝠'),
            (3, 3): (self.primary_guard, '初级卫兵'),
            (0, 1): (self.kulou_leader, '骷髅队长'),
            (1, 0): (self.kulou_leader, '骷髅队长'),
            (5, 2): (self.red_bat, '红蝙蝠'),
            (9, 1): (self.stone_man, '石头怪人'),
            (10, 2): (self.stone_man, '石头怪人'),
            (2, 5): (self.senior_master, '高级法师'),
            (8, 5): (self.senior_master, '高级法师'),
            (6, 0): (self.monster_king, '怪王'),
            (7, 1): (self.monster_king, '怪王'),
            (9, 3): (self.red_master, '红衣法师'),
        }

    def fixed_brick(self):
        self.draw(self.upstairs, self.up_pos[0], self.up_pos[1])
        self.dic[self.up_pos] = '上楼'
        self.draw(self.downstairs, self.down_pos[0], self.down_pos[1])
        self.dic[self.down_pos] = '下楼'
        for i in [(2, 0), (2, 1), (2, 3), (2, 4), (1, 4), (0, 4), (4, 0), (4, 1), (4, 3), (4, 4), (5, 4), (6, 4), (7, 4),
                  (8, 4), (8, 3), (8, 2), (8, 1), (8, 0), (10, 4), (1, 9), (1, 8), (1, 7), (1, 6), (2, 6), (3, 6), (4, 6),
                  (5, 6), (6, 6), (7, 6), (8, 6), (9, 6), (10, 6), (10, 7), (10, 8), (10, 9), (10, 10), (3, 10), (3, 9),
                  (3, 8), (5, 8), (6, 8), (6, 9), (7, 8), (7, 9), (8, 8)]:
            self.draw(self.wall, i[0], i[1])
            self.dic[(i[0], i[1])] = '墙'
        for i in self.ls:
            self.screen.blit(self.road, i)
            self.dic[(int((i[0]-375)/48), int((i[1]-25)/48))] = '路'
